/* **********************************************************************************
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* This source code is subject to terms and conditions of the Shared Source License
* for DSL Editor PowerToy. A copy of the license can be found in the License.htm file
* at the root of this distribution. If you can not locate the Shared Source License
* for DSL Editor PowerToy, please obtain a copy from: http://www.codeplex.com/dsltreegrideditor/Project/License.aspx.
* By using this source code in any fashion, you are agreeing to be bound by
* the terms of the Shared Source License for DSL Editor PowerToy.
*
* You must not remove this notice, or any other, from this software.
*
* **********************************************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace DslEditorPowerToy.Controls.Editors.Special
{
    internal class TextLabelDescriptor : PropertyDescriptor
    {
        private string _text = string.Empty;

        #region Constructors
        public TextLabelDescriptor(string name, string text) 
            : base(name, null)
        {
            this._text = text;
        }
        #endregion


        public override bool CanResetValue(object component)
        {
            //Can't be changed
            return false;
        }

        public override Type ComponentType
        {
            get
            {
                //Any component
                return typeof(object);
            }
        }

        public override object GetValue(object component)
        {
            //Fixed value
            return this._text;
        }

        public override bool IsReadOnly
        {
            get
            {
                //Can't be edited
                return true;
            }
        }

        public override Type PropertyType
        {
            get
            {
                return typeof(string);
            }
        }

        public override void ResetValue(object component)
        {
            //Value does not change
        }

        public override void SetValue(object component, object value)
        {
            //Nothing to change here
        }

        public override bool ShouldSerializeValue(object component)
        {
            //Never different from default value
            return false;
        }
    }
}
